package Demo1.operation;

import Demo1.Book.Book;
import Demo1.Book.Booklist;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("借阅图书");
        System.out.println("请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = booklist.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBooks(i);
            if (book.getName().equals(name)){
                book.setBorrow(true);
                return;
            }
        }
        System.out.println("没有你要借的书");
    }
}
